﻿using System;
using Newtonsoft.Json.Linq;

namespace Wala.Connection.Objects.Timeline
{
    public class FeedComment
    {
        public int type;

        public Comment data;

        public FeedComment()
        {
            type = 3;
            data = new Comment();
        }

        public FeedComment(int type, Comment data)
        {
            this.type = type;
            this.data = data;
        }

        public static FeedComment FromJson(String json)
        {
            try
            {
                JObject jObject = JObject.Parse(json);
                int type = (int)jObject["type"];
                string data = (string)jObject["data"];
                Comment comment = Comment.FromJson(data);

                return new FeedComment(type, comment);
            }
            catch (Exception ex)
            {                
                return new FeedComment();
            }
        }
    }
}
